<%@page import="com.uhaou.system.model.*" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<html>
<head>
	<title><%=SysRole.TABLE_ALIAS%> 维护</title>
	<link type="text/css" rel="stylesheet" href="${ctx}/css/themes/default/easyui.css">
	<link type="text/css" rel="stylesheet" href="${ctx}/css/themes/icon.css">
	<script type="text/javascript" src="${ctx}/scripts/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/scripts/locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
<div style="width:1000px;padding:0px;">
<form id="queryForm" name="queryForm" action="<c:url value="/system/SysRole/listAjax.do"/>" method="post" style="display: inline;">
	<input type="hidden" id="pageNumber" name="pageNumber" value="1"/>
	<input type="hidden" id="pageSize" name="pageSize" value="10" />
	<div class="queryPanel">
		<fieldset>
			<legend>搜索</legend>
			<table>
				<tr>	
					<td class="tdLabel"><%=SysRole.ALIAS_ROLE_NAME%></td>		
					<td>
						<input value="" id="roleName" name="roleName" maxlength="100"  class=""/>
					</td>
					<td class="tdLabel"><%=SysRole.ALIAS_CREATE_TIME%></td>		
					<td>
						<input class="easyui-datebox" value="" id="createTimeBegin" name="createTimeBegin"   />
						<input class="easyui-datebox" value="" id="createTimeEnd" name="createTimeEnd"   />
					</td>
					<td class="tdLabel"><%=SysRole.ALIAS_DELETED%></td>		
					<td>
						<input value="" id="deleted" name="deleted" maxlength="1"  class=""/>
					</td>
					<td class="tdLabel"><%=SysRole.ALIAS_MEMO%></td>		
					<td>
						<input value="" id="memo" name="memo" maxlength="100"  class=""/>
					</td>
				</tr>	
			</table>
		</fieldset>
		<div class="handleControl">
			<input type="submit" class="stdButton" style="width:80px" value="查询" />
		<div>
	</div>
	<br></br>
		<div>
			<table id="userDataGrid"></table>
			<div style="margin-bottom:10px;">
				<a href="#" onclick="resize()">resize</a>
				<a href="#" onclick="getSelected()">getSelected</a>
				<a href="#" onclick="getSelections()">getSelections</a>
				<a href="#" onclick="clearSelections()">clearSelections</a>
				<a href="#" onclick="selectRow()">selectRow</a>
				<a href="#" onclick="selectRecord()">selectRecord</a>
				<a href="#" onclick="unselectRow()">unselectRow</a>
			</div>
		</div>
	</form>
</div>
</body>
<script type="text/javascript">

/**用于回调*/
	 function v_deleteItems(result){
			if (result){
				var rows = $('#userDataGrid').datagrid('getSelections');
				var ids = [];
				if(rows!=null&&rows.length>0){
					$.each(rows,function(i,n){ids.push(n.id)
					});
					$.post( "${ctx}/system/SysRole/delete.do", {"items":ids.join(',')}, 
							function(data){
								$.messager.alert('提示','删除成功','info');
								$('#queryForm').submit();
							}
					);
				}else{
					$.message.alert("请选择后进行删除操作！","warning");
				}
			}
		}
		var option = {
				title:'<%=SysRole.TABLE_ALIAS%>',
				iconCls:'icon-save',
				width:1000,
				height:500,
				nowrap: false,
				striped: true,
				collapsible:true,
				url: "${ctx}/system/SysRole/listAjax.do",                                                       
				remoteSort: false,
				idField:
					'id'
																				,
				columns:[[
					{field:'ck',checkbox:true}
							,{field:'id',title:'<%=SysRole.ALIAS_ID%>',width:120,sortable:true}
							,{field:'roleName',title:'<%=SysRole.ALIAS_ROLE_NAME%>',width:120,sortable:true}
							,{field:'createTimeString',title:'<%=SysRole.ALIAS_CREATE_TIME%>',width:120,sortable:true}
							,{field:'deleted',title:'<%=SysRole.ALIAS_DELETED%>',width:120,sortable:true}
							,{field:'memo',title:'<%=SysRole.ALIAS_MEMO%>',width:120,sortable:true}
				]],
				pagination:true,
				rownumbers:true,
				toolbar:[
				{
					id:'btnview',
					text:'查看',
					iconCls:'icon-view',
					handler:function(){
						var selected = $('#userDataGrid').datagrid('getSelected');
						if (selected){
							location.href="${ctx}/system/SysRole/show.do?id="+selected.id;
						}
					}
				},'-',{
					id:'btnadd',
					text:'新增',
					iconCls:'icon-add',
					handler:function(){
							location.href="${ctx}/system/SysRole/create.do";
					}
				},{
					id:'btnedit',
					text:'修改',
					iconCls:'icon-edit',
					handler:function(){
						var selected = $('#userDataGrid').datagrid('getSelected');
						if (selected){
							location.href="${ctx}/system/SysRole/edit.do?id="
							+selected.id;
						}
					}
				},{
					id:'btndelete',
					text:'删除',
					iconCls:'icon-no',
					handler:function(){
					$.messager.confirm('确认', "确定要删除吗？" ,v_deleteItems);
					}
				}]
			}


		//重要$(document).ready(handler)
		$(function(){
			//设置form为ajax提交		
			$('#queryForm').form({
				success:function(data){
				data = eval('('+data+')');
				$('#userDataGrid').datagrid("loadData",data);
				}
			});
			//设置datagrid		
			$('#userDataGrid').datagrid(option);
			//设置底部的上一页和下一页
			var p = $('#userDataGrid').datagrid('getPager');
			if (p){
				$(p).pagination({
					onBeforeRefresh:function(){
						alert('before refresh');
					}
				});
				$(p).pagination({
					onSelectPage:function(pageNumber,pageSize){
						$("input[name='pageNumber']").val(pageNumber);
						$("input[name='pageSize']").val(pageSize);
						$('#queryForm').submit();
					}
				});
			}}
		); //end $(document).ready(handler)
		//以下这些方法放在这几是为了提供编写javascript参考用，可根据实际情况删除
		function resize(){
			$('#userDataGrid').datagrid('resize', {
				width:1100,
				height:400
			});
		}
		function getSelected(){
			var selected = $('#userDataGrid').datagrid('getSelected');
			if (selected){
				alert(selected.id);
			}
		}
		function getSelections(){
			var ids = [];
			var rows = $('#userDataGrid').datagrid('getSelections');
			for(var i=0;i<rows.length;i++){
				ids.push(rows[i].id);
			}
			alert(ids.join(':'));
		}
		function clearSelections(){
			$('#userDataGrid').datagrid('clearSelections');
		}
		function selectRow(){
			$('#userDataGrid').datagrid('selectRow',1); //行号从0开始
		}
		function selectRecord(){
			$('#userDataGrid').datagrid('selectRecord','1'); //'1'是id值
		}
		function unselectRow(){
			$('#userDataGrid').datagrid('unselectRow',1);//行号从0开始
		}
	</script>
</html>


